package cn.kdlc.demo.bind.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import cn.kdlc.demo.bind.R;
import cn.kdlc.demo.bind.model.User;

import java.util.List;

/**
 * Created by android on 2015/11/24 0024.
 */
public class UserAdapter extends RecyclerView.Adapter<UserHolder> {
    private List<User> list;

    public UserAdapter(List<User> list) {
        this.list = list;
    }

    @Override
    public UserHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item, parent, false);
        UserHolder holder = new UserHolder(itemView);
        return holder;
    }

    @Override
    public void onBindViewHolder(UserHolder holder, int position) {
        User user = list.get(position);
        holder.bind(user);
    }

    @Override
    public int getItemCount() {
        return list.size();
    }
}
